package com.briup.cms.web.controller;

import com.briup.cms.service.IBaseUserService;
import com.briup.cms.utils.Message;
import com.briup.cms.utils.MessageUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description
 * @Author lining
 * @Date 2021/7/17 16:13
 * @Version 1.0.0
 */
@RestController
@Api(tags = "登录相关接口")
public class LoginController {
    @Autowired
    private IBaseUserService service;
    @ApiOperation("用户登录")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "username",value = "用户名"),
            @ApiImplicitParam(name = "password",value = "密码")
    })
    @PostMapping("/login")
    public Message login(String username,String password){
        //1.调用service代码
        String token = service.login(username, password);
        //2.作出响应
        return MessageUtil.success(token);
    }
    @PostMapping("/logout")
    public Message logout(){
        //当后端程序中，对登录用户的登录状态进行保存，就需要在退出逻辑修改登录状态信息
        return MessageUtil.success("退出成功");
    }
}
